<script>
    // toUpperCase: 字符串全部转大写
    let str1 = 'zzc like csgo';
    console.log(str1.toUpperCase());


    // toLowerCase:字符串全部转小写
    let str2 = 'ZZC like CSGO';
    console.log(str2.toLowerCase());


    // charAt: 获取指定下标的字符
    let str3 = 'helloWorld';
    console.log(str3.charAt(1));


    // substring: 截取字符串,不包含末尾，输入一个截取后面全部
    let str4 = 'helloWorld';
    console.log(str4.substring(0, 5));   //hello
    console.log(str4.substring(5));   //World


    // 思考题：将字符串首字母转大写，其他字母都小写
    let str5 = 'aBcDefG';
    let result = str5.charAt(0).toUpperCase() + str5.substring(1).toLowerCase();
    console.log(result);


    // trim去除空格、trimStart、trimEnd
    let str6 = '   hello   ZZC   ';
    console.log(str6.trim());
    console.log(str6.trimStart());
    console.log(str6.trimEnd());


    // includes：判断是否存在子串(true/false)
    let str7 = 'abcdefg';
    console.log(str7.includes('de'));//true
    console.log(str7.includes('deggggg'));//false


    // indexOf：检测子串存在目标字符串中的首次下标，没找到返回 -1
    let str8 = 'abcdefabcdefg';
    console.log(str8.indexOf('de'));//3
    console.log(str8.indexOf('zzz'));//-1
    console.log(str8.lastIndexOf('de'));//9


    // repeat：重复一个字符串多少次
    let str9 = '*';
    console.log(str9.repeat(4));


    // replace：替换字符串
    let str10 = 'ZZC like look yellow';
    console.log(str10.replace('yellow', 'CSGO'))


    // split： 用特定字符炸开字符串
    let str11 = 'ZZC|like|look|beautiful|woman';
    console.log(str11.split('|'));


    // 需求：隐藏手机号中间四位
    //方法一
    let phone = '15866669999';
    let firstPhone = phone.substring(0, 3) + '****' + phone.substring(7);
    console.log(firstPhone);
    //方法二
    console.log(phone.replace(phone.substring(3, 7), '****'));


</script>